home *** CD-ROM | disk | FTP | other *** search
- include lmacros.h
-
- procdef write_scc,<<ctl,word>,<reg,byte>,<val,byte>>
- pushf
- mov dx,ctl
- mov al,reg
- cmp al,0
- jz wr0 ; no need to set register 0
- cli
- out dx,al
- ; allow enough delay for 10 MHz 80286 and a 3.6 MHz 8530
- ; each nop is 3 clock ticks (300 ns @ 10 MHz).
- ; The 8530 requires a delay of 6 PCLK cycles (1.666 uS at 3.6 MHz)
- nop
- nop
- nop
- nop
- nop
- nop
- wr0: mov al,val
- out dx,al
- popf
- pret
- pend write_scc
-
- procdef read_scc,<<ctl1,word>,<reg1,byte>>
- pushf
- mov dx,ctl1
- mov al,reg1
- cmp al,0
- jz rd0 ; no need to set reg if R0
- cli
- out dx,al
- ; allow enough delay for 10 MHz 80286 and a 3.6 MHz 8530
- nop
- nop
- nop
- nop
- nop
- nop
- rd0: in al,dx
- mov ah,0
- popf
- pret
- pend read_scc
-
- ; Read packets from the 8530 receiver.
- ; Returns when either a good frame is received, or when carrier drops.
- ; If a good frame is received, the length is returned; otherwise -1.
- procdef rx8530,<<control,word>,<data,word>,<buf,ptr>,<bufsize,word>>
-
- cld
- push di
-
- restart:mov cx,0 ; cnt = 0
- mov di,buf ; cp = buf
-
- rxloop: mov dx,control ; read status
- in al,dx ; into al
- test al,08h ; DCD still present?
- jz dcdoff ; nope, quit
- test al,080h ; Abort?
- jnz restart ; yes, start again
- test al,01h ; character available?
- jz nochar ; nope, go on
- mov dx,data
- in al,dx ; get it
- stosb ; and stash: *cp++ = char
- inc cx ; cnt++
- cmp cx,bufsize ; cx == bufsize?
- jnz rxloop
-
- mov dx,control ; buffer overflowed; abort receiver
- mov al,3 ; select register 3
- out dx,al
- mov al,0d9h ; ENT_HM|RxENABLE|RxCRC_ENAB|Rx8
- nop
- nop
- nop
- nop
- nop
- out dx,al
- jmp restart
-
- nochar: mov al,1 ; Select error register (R1)
- mov dx,control
- out dx,al
- nop
- nop
- nop
- nop
- nop
- nop
- in al,dx ; read error reg (R1)
- test al,080h ; end of frame?
- jz rxloop ; nope, keep looking
-
- test al,040h ; End of frame. CRC error?
- jnz restart ; yup; start again
- mov ax,cx ; good frame; return with count
- pop di
- pret
-
- dcdoff:
- mov ax,0ffffh ; DCD dropped, return -1
- pop di
- pret
-
- pend rx8530
- end
-
-